﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

using libtcod;

namespace Threshold.UserInterface
{
	class Time
	{
		private const float MINUTES_IN_DAY = 1440;
		private float _minutes;  // count of game minutes that have passed
		private float _secondsInGameMinute = 1; // how many seconds in a game minute
		private float _interval; 

		public void Draw(libtcod.TCODConsole console)
		{
			int length = (int)(80 * (_minutes / MINUTES_IN_DAY));
			int blockCharacter = 219;

			console.setForegroundColor(TCODColor.yellow);
			for (int counter = 0; counter < length; counter++)
			{
				console.putChar(counter, 0, blockCharacter, TCODBackgroundFlag.None);
			}
		}

		public void Update(libtcod.TCODKey key, libtcod.TCODMouseData mouse, float lastFrameLength)
		{
			_interval += lastFrameLength;
			if (_interval > _secondsInGameMinute)
			{
				_interval -= _secondsInGameMinute;

				_minutes += 1;

				Debug.WriteLine(_minutes);
				Debug.WriteLine(80 * (_minutes / MINUTES_IN_DAY));

				if (_minutes > 1440)
				{
					_minutes = 0;
				}
			}

		}

	}
}
